using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace KbsUmlEditor
{
    class UMLLijn: UMLObject
    {
        UMLPunt.Type m_BeginPunt;

        internal UMLPunt.Type BeginPunt
        {
            get { return m_BeginPunt; }
            set { m_BeginPunt = value; }
        }
        UMLPunt.Type m_EindPunt;

        internal UMLPunt.Type EindPunt
        {
            get { return m_EindPunt; }
            set { m_EindPunt = value; }
        }

        public UMLLijn(Point beginPositie, Point eindPositie, UMLPunt.Type beginPuntType, UMLPunt.Type eindPuntType ):base(beginPositie, eindPositie)
        {
            m_BeginPunt = beginPuntType;
            m_EindPunt = eindPuntType;
            
        }
        public override void Teken(Graphics g, double factor, int grid)
        {
            System.Drawing.Pen myPen;
            myPen = new System.Drawing.Pen(System.Drawing.Color.Black);
            System.Drawing.Graphics formGraphics = g;
            Point bPos = new Point((int)(base.BeginPositie.X * grid * factor), (int)(base.BeginPositie.Y * grid * factor));
            Point ePos = new Point((int)(base.EindPositie.X * grid * factor), (int)(base.EindPositie.Y * grid * factor));

            //bPos.X = (int)((double)bPos.X * factor);
            //bPos.Y = (int)((double)bPos.Y * factor);
            //ePos.X = (int)((double)ePos.X * factor);
            //ePos.Y = (int)((double)ePos.Y * factor);
            //Teken de lijn
            formGraphics.DrawLine(myPen, bPos, ePos);
           
            //Peter06032009

            //Teken de punten
            UMLPunt.Type hulp;
            String hulp1;
            for (int x = 1; x < 3; x++) 
            {
                if (x == 1) 
                {
                    hulp = m_BeginPunt;
                    hulp1 = "begin";
                }
                else 
                { 
                    hulp = m_EindPunt;
                    hulp1 = "eind";
                }

                //Alleen wanneer de lijn een punt heeft
                if (hulp !=UMLPunt.Type.normal)
                {
                    switch (hulp)
                    {
                        case UMLPunt.Type.association:
                            UMLAssociation ass = new UMLAssociation(BeginPositie, EindPositie, hulp1);
                            ass.Teken(g, factor, grid);
                            break;
                        case UMLPunt.Type.aggregation:
                            UMLAggregation agg = new UMLAggregation(BeginPositie, EindPositie, hulp1);
                            agg.Teken(g, factor, grid);
                            break;
                        case UMLPunt.Type.composition:
                            UMLComposition com = new UMLComposition(BeginPositie, EindPositie, hulp1);
                            com.Teken(g, factor, grid);
                            break;
                        case UMLPunt.Type.generalization:
                            UMLGeneralization gen = new UMLGeneralization(BeginPositie, EindPositie, hulp1);
                            gen.Teken(g, factor, grid);
                            break;
                    }
                }
                
            }
            //formGraphics.Dispose();
        }


    }
}
